package org.garden.common.utils;

public class UriUtil {

    public static void build(StringBuilder builder, String key, String value) {
        StringBuilder param = new StringBuilder(key).append("=").append(value);
        int index = builder.lastIndexOf("?");
        if(index == -1) {
            builder.append("?").append(param);
            return;
        }
        if(index == builder.length() - 1) {
            builder.append(param);
            return;
        }
        if(builder.lastIndexOf("&") == builder.length() - 1) {
            builder.append(param);
        } else {
            builder.append("&").append(param);
        }
    }
}
